package com.viewlibrary.loadview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * 实体小圆
 */
public class CircleView extends View {
    Paint mPaint;
    int mColor;
    public CircleView(Context context) {
        this(context,null);
    }

    public CircleView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public CircleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mPaint=new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);//防抖动
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2,mPaint);
    }

    public void exChangeColor(int color){
        mColor=color;
        mPaint.setColor(mColor);
        invalidate();
    }
    public int getCurrentColor(){
        return mColor;
    }
}
